﻿using Mengsk.ProxyDelivery.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mengsk.ProxyDelivery.Service
{
    public class ShoesSkuService : ServiceBase<ShoesSku>
    {
        const string APIURL_INSERT = "/webservice/shoes/insertsku.html";
        const string APIURL_UPDATE = "/webservice/shoes/updatesku.html";
        const string APIURL_DELETE = "/webservice/shoes/deletesku.html";
        const string APIURL_DELETEBYSHOESID = "/webservice/shoes/deleteskubyshoesid.html";

        public void Insert(ShoesSku shoesSku)
        {
            IDictionary<string, string> para = new Dictionary<string, string>();
            para.Add("shoesId", shoesSku.ShoesId.ToString());
            para.Add("edtion", shoesSku.Edtion);
            para.Add("color", shoesSku.Color);
            para.Add("size", shoesSku.Size);
            para.Add("price", shoesSku.Price.ToString("F0"));
            para.Add("offLinePrice", shoesSku.OffLinePrice.ToString("F0"));

            this.DoPost<int>(APIURL_INSERT, para);
        }

        public void Update(ShoesSku shoesSku)
        {
            IDictionary<string, string> para = new Dictionary<string, string>();
            para.Add("id", shoesSku.Id.ToString());
            para.Add("edtion", shoesSku.Edtion);
            para.Add("color", shoesSku.Color);
            para.Add("size", shoesSku.Size);
            para.Add("price", shoesSku.Price.ToString("F0"));
            para.Add("offLinePrice", shoesSku.OffLinePrice.ToString("F0"));

            this.DoPost<int>(APIURL_INSERT, para);
        }

        public void Delete(int id)
        {
            IDictionary<string, string> para = new Dictionary<string, string>();
            para.Add("id", id.ToString());
            this.DoPost<int>(APIURL_INSERT, para);
        }

        public void DeleteByShoesId(int shoesId)
        {
            IDictionary<string, string> para = new Dictionary<string, string>();
            para.Add("shoesId", shoesId.ToString());
            this.DoPost<int>(APIURL_DELETEBYSHOESID, para);
        }
    }
}
